package com.lw.entity.table;

import com.mybatisflex.core.query.QueryColumn;
import com.mybatisflex.core.table.TableDef;

import java.io.Serial;

/**
 * 代码生成字段配置表 表定义层。
 *
 * @author lw
 * @since 2025年05月28日 00:20:25
 */
public class TbGenFieldConfigTableDef extends TableDef {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 代码生成字段配置表
     */
    public static final TbGenFieldConfigTableDef TB_GEN_FIELD_CONFIG = new TbGenFieldConfigTableDef();

    
    public final QueryColumn ID = new QueryColumn(this, "id");

    /**
     * 关联的配置ID
     */
    public final QueryColumn CONFIG_ID = new QueryColumn(this, "config_id");

    /**
     * 字典类型
     */
    public final QueryColumn DICT_TYPE = new QueryColumn(this, "dict_type");

    /**
     * 表单类型
     */
    public final QueryColumn FORM_TYPE = new QueryColumn(this, "form_type");

    /**
     * 字段名称
     */
    public final QueryColumn FIELD_NAME = new QueryColumn(this, "field_name");

    /**
     * 字段排序
     */
    public final QueryColumn FIELD_SORT = new QueryColumn(this, "field_sort");

    /**
     * 字段类型
     */
    public final QueryColumn FIELD_TYPE = new QueryColumn(this, "field_type");

    
    public final QueryColumn MAX_LENGTH = new QueryColumn(this, "max_length");

    /**
     * 查询方式
     */
    public final QueryColumn QUERY_TYPE = new QueryColumn(this, "query_type");

    
    public final QueryColumn COLUMN_NAME = new QueryColumn(this, "column_name");

    
    public final QueryColumn COLUMN_TYPE = new QueryColumn(this, "column_type");

    /**
     * 创建时间
     */
    public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");

    /**
     * 是否必填
     */
    public final QueryColumn IS_REQUIRED = new QueryColumn(this, "is_required");

    /**
     * 更新时间
     */
    public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");

    
    public final QueryColumn COLUMN_LENGTH = new QueryColumn(this, "column_length");

    /**
     * 字段描述
     */
    public final QueryColumn FIELD_COMMENT = new QueryColumn(this, "field_comment");

    /**
     * 是否在表单显示
     */
    public final QueryColumn IS_SHOW_IN_FORM = new QueryColumn(this, "is_show_in_form");

    /**
     * 是否在列表显示
     */
    public final QueryColumn IS_SHOW_IN_LIST = new QueryColumn(this, "is_show_in_list");

    /**
     * 是否在查询条件显示
     */
    public final QueryColumn IS_SHOW_IN_QUERY = new QueryColumn(this, "is_show_in_query");

    /**
     * 所有字段。
     */
    public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");

    /**
     * 默认字段，不包含逻辑删除或者 large 等字段。
     */
    public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, CONFIG_ID, COLUMN_NAME, COLUMN_TYPE, COLUMN_LENGTH, FIELD_NAME, FIELD_TYPE, FIELD_SORT, FIELD_COMMENT, MAX_LENGTH, IS_REQUIRED, IS_SHOW_IN_LIST, IS_SHOW_IN_FORM, IS_SHOW_IN_QUERY, QUERY_TYPE, FORM_TYPE, DICT_TYPE, CREATE_TIME, UPDATE_TIME};

    public TbGenFieldConfigTableDef() {
        super("", "tb_gen_field_config");
    }

    private TbGenFieldConfigTableDef(String schema, String name, String alisa) {
        super(schema, name, alisa);
    }

    public TbGenFieldConfigTableDef as(String alias) {
        String key = getNameWithSchema() + "." + alias;
        return getCache(key, k -> new TbGenFieldConfigTableDef("", "tb_gen_field_config", alias));
    }

}
